<template>

  <div class="tubiao">
    <p><span>近期工作效率</span></p>
  </div>
  <div class="tubiao-right">
    <p><span>日程管理</span></p>
    <el-scrollbar ref="scrollbarRef" height="400px" always @scroll="scroll">
    <div ref="innerRef">
      <p v-for="item in 20" :key="item" class="scrollbar-demo-item">
        {{ item }}
      </p>
    </div>
  </el-scrollbar>

  <el-slider
    v-model="value"
    :max="max"
    :format-tooltip="formatTooltip"
    @input="inputSlider"
  />
  </div>
</template>
<script setup>
console.log('图表')
import * as echarts from 'echarts'
import { onMounted, ref } from 'vue'
onMounted(() => {
    let myChart = echarts.init(document.querySelector('.tubiao'));
    let option = {
        xAxis: {
            type: 'category',
            data: ['10.01', '10.02', '10.03', '10.04', '10.05', '10.06', '10.07']
        },
        yAxis: {
            type: 'value',
            data:['20%','40%','60%','80%','100%']
        },
        series: [{
            data: [Math.random()*100, Math.random()*100, Math.random()*100, Math.random()*100, Math.random()*100, Math.random()*100, Math.random()*100],
            type: 'line',
        }]
    };
    myChart.setOption(option);
})
import { ElScrollbar } from 'element-plus'

const max = ref(0)
const value = ref(0)
const innerRef = ref()
const scrollbarRef = ref()

onMounted(() => {
  max.value = innerRef.value.clientHeight - 380
})

const inputSlider = (value) => {
  scrollbarRef.value.setScrollTop(value)
}
const scroll = ({ scrollTop }) => {
  value.value = scrollTop
}
const formatTooltip = (value) => {
  // return `${value} px`
  return `越往后越糟心`

}
</script>

<style scoped lang="less">
.tubiao{
    height: 180px;
    background: #fff;
    margin-top: 10px;
    float: left;
    position: relative;
    width: calc(73% - 20px);
    padding-right: 20px;
}
 .scrollbar-demo-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  margin: 10px;
  text-align: center;
  border-radius: 4px;
  background: var(--el-color-primary-light-9);
  color: var(--el-color-primary);
}
.el-slider {
  margin-top: 20px;
}
.tubiao-right{
    width: 25%;
    height: 136px;
    float: right;
    background: #fff;
    margin-top: 10px;
    padding-top: 10px;
}
p{
    line-height: 0px;
    font-size: 12px;
    color: #797777;
    z-index: 999;
    margin-top: 0px;
}
p span{
    float: left;
    font-size: 14px;
}
/deep/ .el-slider{
  height: 0px !important;
}
</style>
